function Y_pseudo = zFC_GenerateVARData(Yinit, Ahat, Resid, Ahat_determ, X_determ)

% same but don't randomize on residuals, do it in main m file
% -----------------------------------------------------%
% DESCRIPTION OF THE FUNCTION
% this function estimates the reduced-form VAR model for the variables
% included in the matrix Y. 
%
% -----------------------------------------------------%

% generates pseudo data bootstraping RFresiduals, using coefficients
% "Consthat, Trendhat, Seasonhat" to generate the model and using the true
% realizations of Y as the first p observations, before then using the
% iterations of the model

% Y = data';
% 
% step = B_post';
% Ahat = step(:,1:p*n);
% Consthat = step(:,p*n+1);
% Trendhat = zeros(n,1);
% RFresiduals = Resid';
% 
% Seasonhat = zeros(n,n);
% season_dummies = zeros(T_used,n);


% % % assert(size(Trendhat,2) == 1)

k = size(Ahat,1);
p = size(Ahat,2)/k;
assert( size(Yinit,1) == k)
assert( size(Yinit,2) == p)
T_used = size(Resid,2);
T = T_used + p;

Y_pseudo = zeros(k,T);
Y_pseudo(:,1:p) = Yinit(:,1:p); 

for j=1:T_used 
    step1 = Y_pseudo(:,p+j-p:p+j-1);
    step2 = fliplr(step1);
    step3 = reshape(step2,k*p,1);
    Y_pseudo(:,j+p) =  Ahat*step3 + Ahat_determ*X_determ(j,:)' + Resid(:,j); 
end

end




